﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
// Copyright (C) 2017 ZyCoder
// 版权所有。 
//
// 文件名：RuntimeCache
// 
// 创建者：名字 (zycoder)
// 时间：2018/2/25 17:33:17
//
// 版本：V1.0.0
// 网站: http://www.cnblogs.com/zycoder
//----------------------------------------------------------------*/
#endregion

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Caching;

namespace yunlive.Infrastructure.Cache
{
    public class RuntimeCache : ICache
    {
        private static readonly System.Web.Caching.Cache httpRuntimeCache = System.Web.HttpRuntime.Cache;
        private static readonly int _expireMinutes = int.Parse(ConfigurationManager.AppSettings["_expireMinutes"]);
        public void Delete(string key)
        {
            httpRuntimeCache.Remove(key);
        }

        public object Get(string key)
        {
            return httpRuntimeCache.Get(key);
        }

        public void Put(string key, object value)
        {
            httpRuntimeCache.Insert(key, value);
        }

        public void Put(string key, object value, int expireMinutes)
        {
            httpRuntimeCache.Insert(key, value, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1));
        }
    }
}
